#pragma once

template <class T> 
class Singleton
{
private:
	Singleton(const Singleton<T> &);

	Singleton& operator=(const Singleton<T> &);

protected:

	static T* ms_Singleton;

public:
	Singleton( void )
	{
		assert( !ms_Singleton );
		ms_Singleton = static_cast< T* >( this );
	}

	~Singleton( void )
	{  
		if( ms_Singleton != NULL )
			delete ms_Singleton;

		ms_Singleton = 0;  
	}

	static T* getSingletonPtr( void )
	{	
		if( ms_Singleton == NULL )
			ms_Singleton = new T;

		return ms_Singleton; 
	}

	static T& getSingleton( void )
	{
		if( ms_Singleton == NULL )
			ms_Singleton = new T;

		return *ms_Singleton;
	}
};

template<class T> T* Singleton<T>::ms_Singleton = 0;